package com.leetcode.problems009;


/**
 * @Description https://leetcode-cn.com/problems/string-to-integer-atoi/
 * @Date 2021/11/20 14:34
 * @Author ghery
 * @Version V1.0
 */
public class Solution {



    public boolean isPalindrome(int x) {
        if(x < 0){
            return false;
        }
        if(x < 10){
            return true;
        }
        int reverseX = reverse(x);
        return reverseX == x;
    }

    private int reverse(int x) {
        long n = 0;
        while(x != 0){
            n = n * 10 + x % 10;
            x = x /10;
        }
        return (int)n;
    }

    public static void main(String[] args) {
        System.out.println(new Solution().isPalindrome(1222232221));
    }
}
